<script type="text/javascript">
    $(document).ready(function () {
        $('#is_presell_1').click(function () {

            $('#is_presell').show();
            $('#is_presell2').hide();
        });
        $('#is_presell_0').click(function () {
            $('#is_presell').hide();
            $('#is_presell2').show();
        });
    });
</script>
<div class="admin">
    <form method="post" name="myform" id="myform" action="">
        <div class="tab panel dux-tab admin-panel">
            <div class="panel-head">
                <div class="tab-head">
                    <strong>添加商品</strong>
                    <ul class="tab-nav">
                        <li class="active"><a href="#tab-1">基本信息</a></li>
                    </ul>
                </div>
            </div>
            <div class="tab-body">
                <div class="tab-panel active" id="tab-1">
                    <table class="table table-hover">
                        <tr>
                            <td width='160px'><span class="c-red">*</span>商品分类：</td>
                            <td id="recommend_gcategory">
                                <input type="hidden" id="cate_id" name="class3" value="{$goods['goods_class']}" class="mls_id" />
                                <input type="hidden" id="cate_name" name="classname" value="{$goods['goods_classname']}" class="mls_names" />
                            </td>
                            <td width='*'></td>
                        </tr>
                        <tr>
                            <td width='160px'><span class="c-red">*</span>商品名称：</td>
                            <td width='*'>
                                <input type="text" class="input input_big" value="{$goods['goods_title']}" datatype="*" placeholder="" id="" name="goods_title" />
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td width='*'></td>
                        </tr>
                        <tr>
                            <td width='160px'><span class="c-red">*</span>商品货号：</td>
                            <td width='*'>
                                <input type="text" class="input input_big" value="{$goods['goods_number']}" datatype="*" placeholder="" id="" name="goods_number" />
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td width='*'></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>轮播图片：</td>
                            <td>
                                <div class="goodspic-uplaod">
                                    <!-- 图片上传按钮 -->
                                    <input class="fileupload" type="file" name="image" data-name="goods_images[]" data-num="5" />
                                    <!-- 图片展示模块 -->
                                    <div class="files">
                                        <foreach item="v" name="goods['images']" key='k'>
                                            <div class="images_zone">
                                                <input type="hidden" name="goods_images[]" value="{$v}">
                                                <span><img src="{$v}!100x100"></span>
                                                <a class="deldre_img" href="javascript:;" style="display: none;">删除</a>
                                                <if condition="$v == $goods['goods_thumb']">
                                                <a class="deld_zhutu" href="javascript:;" style="top:0;display:block;background-color:#fde3e9;">已设为主图</a>
                                                <input type="hidden" class="deld_input" name="goods_thumb" value="{$goods['goods_thumb']}">
                                                </if>
                                            </div>
                                        </foreach>
                                    </div>
                                    <div style="clear:both;"></div>
                                    <!-- 图片上传进度条模块 -->
                                    <div class="up_progress"><div class="progress-bar"></div></div>
                                </div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>进货价：</td>
                            <td>
                                <input name="goods_stockprice" class="inputL input_smallL" datatype="*" type="text" value="{$goods['goods_stockprice']}" /><em class="add-on">元</em>
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>销售价：</td>
                            <td>
                                <input name="goods_price" class="inputL input_smallL" datatype="*" type="text"  value="{$goods['goods_price']}" /><em class="add-on">元</em>
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>市场价：</td>
                            <td>
                                <input name="goods_markprice" class="inputL input_smallL" datatype="*" type="text" value="{$goods['goods_markprice']}" /><em class="add-on">元</em>
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>库存：</td>
                            <td>
                                <input name="goods_stock" class="inputL input_smallL" datatype="*" type="text" value="{$goods['goods_stock']}" /><em class="add-on">件</em>
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>所属店铺：</td>
                            <td>
                                <input name="goods_store" class="inputL input_big" datatype="*" type="text" value="{$goods['goods_store']}" />
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>简短描述：</td>
                            <td>
                                <textarea class="input input_big" name="goods_buytitle" id="voucher_desc" cols="62" rows="3">{$goods['goods_buytitle']}</textarea>
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                            <tr>
                                <td><span class="c-red">*</span>店铺分类：</td>
                                <td>
                                    <select name="stc_id" class="inputL input_small">
                                        <option value="0">请选择</option>
                                        <foreach item="v" name="storeClass">
                                            <option value="{$v['stc_id']}" <if condition="$v['stc_id'] eq $goods['stc_id']">selected="selected"</if>>{$v['stc_name']}</option>
                                        </foreach>
                                    </select>
                                    <div class="label Validform_checktip"></div>
                                </td>
                                <td></td>
                            </tr>
                    </table>

                    <table class="table table-hover">
                        <tr>
                            <td>
                                <script type="text/javascript" charset="utf-8" src="/Public/ueditor1_4_3/ueditor.config.js"></script>
                                <script type="text/javascript" charset="utf-8" src="/Public/ueditor1_4_3/ueditor.all.min.js"></script>
                                <script type="text/javascript" charset="utf-8" src="/Public/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
                                <textarea id="editor" type="text/plain" style="width:72%;height:200px;" name="goods_content" >{$goods['goods_content']}</textarea>
                                <script>
                                    var ue = UE.getEditor('editor',{
                                        autoFloatEnabled:false,
                                        elementPathEnabled:false
                                    });
                                    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
                                    UE.Editor.prototype.getActionUrl = function (action) {
                                        if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
                                            return '{:STORE_URL}/Store/ueditor';
                                        } else {
                                            return this._bkGetActionUrl.call(this, action);
                                        }
                                    }
                                </script>
                            </td>
                        </tr>
                    </table>
                    
                    <table class="table table-hover">
                        <tr>
                            <td><span class="c-red">*</span>参数：</td>
                            <td>
                                <div class="attr">
                                    <foreach item="v" name="parainfo">
                                        <div class="ncsc-mansong-rule">
                                            <span>商品参数&nbsp;<input name="para_name[]" value="{$v['paraname']}" class="inputL input_smallL" type="text">，</span>
                                            <span>参数值&nbsp;<input name="para_value[]" value="{$v['value']}" class="inputL input_smallL" type="text"></span>
                                        </div>
                                    </foreach>
                                </div>
                                <span id="addattr" class="button bg-blue"><i class="icon-plus"></i> 添加参数</span>
                                <span id="reduceattr" class="button bg-blue"><i class="icon-minus"></i> 减少参数</span>
                            </td>
                            <td></td>
                        </tr>
                    </table>
                    <table class="table table-hover">
                        <tr>
                            <td><span class="c-red">*</span>参数：</td>
                            <td>
                    <div class="guige_show">
                        <div class="guige">
                            <div>
                                <label>规格名称</label>
                                <input id="class_name" type="text" name="sex" placeholder="请输入规格名称" />
                            </div>
                            <div>
                                <label>规格值</label>
                                <input id="class_data" type="text" name="sex" class="guige_date" placeholder="(多规格请使用逗号隔开)例：红色,白色" />
                                <select class="guige_ji">
                                    <option value='0'>添加至1级规格</option>
                                    <option value='1'>添加至2级规格</option>
                                </select>
                                <input type="button" class="guige_tijiao" value="添加" />
                            </div>
                        </div>
                        <div class="guige_show_tian">
                            <foreach item='v' name='attr' key='k'>
                            <div class="guige_show_tian_div">
                                <label><span>{$v['guige']}：</span><input name="class{$k}" type="hidden" value="{$v['guige']}"></label>
                                <foreach item='m' name='v.class' key='e'>
                                    <p><strong data-id="class{$k}:0{$e}" class="guige_add_click"></strong><input name="class{$k}_level[]" value="{$m['name']}" checked="checked" type="checkbox">{$m['name']}<span class="guige_deldte">×</span></p>
                                </foreach>
                            </div>
                            </foreach>
                        </div>
                    </div>
					<script>
						var date_linshi={$att};
						//var date_linshi={'floor[class0:00_class1:00]': "242", 'price[class0:00_class1:00]': "24", 'fprice[class0:00_class1:00]': "28.80", 'stock[class0:00_class1:00]': "242", 'floor[class0:00_class1:10]': "242"}
					</script>
                    <div class="guige_xiugai">
                            <div class="guige_xiugai_tittle">
                                <span>规格名1</span>
                                <span>规格名2</span>
                                <span>底价</span>
                                <span>现价</span>
                                <span>市场价</span>
                                <span>库存</span>
                            </div>
                            <div class="guige_xiugai_main">
                                <table class="guige_xiugai_main_table" border="0" cellspacing="0" cellpadding="0">
                                </table>
                            </div>
                    </div>
                            </td>
                            <td></td>
                        </tr>
                    </table>

                    <table class="table table-hover">
                        <tr>
                            <td width='160px'><span class="c-red">*</span>运费类型：</td>
                            <td width='*'>
                                <div class="field">
                                    <div class="button-group button-group-small radio">
                                        <if condition="$goods['transport_id'] eq 0">
                                            <label class="button"><input name="vr_status" id="is_presell_1" value="1" type="radio"><span class="icon icon-check"></span>运费模版</label>
                                            <label class="button active"><input name="vr_status" id="is_presell_0" checked="checked" value="0" type="radio"><span class="icon icon-times"></span>免运费</label>
                                        <else />
                                            <label class="button active"><input name="vr_status" id="is_presell_1" value="1" checked="checked" type="radio"><span class="icon icon-check"></span>运费模版</label>
                                            <label class="button"><input name="vr_status" id="is_presell_0" value="0" type="radio"><span class="icon icon-times"></span>免运费</label>
                                        </if>
                                    </div>
                                </div>
                            </td>
                            <td width='*'></td>
                        </tr>
                    </table>

                    <table class="table table-hover" id="is_presell">
                            <tr>
                                <td width='160px'><span class="c-red">*</span>选择模版：</td>
                                <td>
                                    <select name="transport_id" class="inputL input_small">
                                        <option value="0">请选择</option>
                                        <foreach item="v" name="transport">
                                            <option value="{$v['id']}" <if condition="$v['id'] eq $goods['transport_id']">selected="selected"</if>>{$v['title']}</option>
                                        </foreach>
                                    </select>
                                    <div class="label Validform_checktip"></div>
                                </td>
                                <td></td>
                            </tr>
                    </table>
                </div>
            </div>
            <div class="panel-foot text-center">
                <div class="form-button">
                    <input type="hidden" value="{$goods['goods_id']}" name="goods_id">
                    <input class="button bg-main" type="submit" value="确认保存">
                    <button class="button bg" type="reset">取消</button>
                </div>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="__JS__/jquery.uploads.js"></script>
<script type="text/javascript" src="__JS__/store/addclass.js"></script>
<script type="text/javascript">
    $("#myform").Validform({
        tiptype: 3,
        showAllError: true,
    });

    $('#myform').layer({
    });

    $('#query_start_time').duxTime({
    timepicker: false,
            minDate: 0,
            format: "Y-m-d"
    });
            addselects({$chooseid_json}, {$gc_json});
            gcategoryInit("recommend_gcategory");
//初始化分类选项
    function addselects(a, b) {
        var html = "<select class=\"inputL input_small\">";
        for (var i in b.class) {
            var selected
            if (b.class[i].cat_id == a[0]) {
                selected = "selected=selected";
            } else {
                selected = false;
            }
            html += '<option ' + selected + ' value="' + b.class[i].cat_id + '">' + b.class[i].cat_name + '</option>';
        }
        html += "</select>";
        $('#recommend_gcategory').append(html);
        for (var i in b.class) {
            try {
                if (typeof (b.class[i].cat_id) == "undefined") {
                } else {
                    if (b.class[i].cat_id == a[0]) {
                        b = b.class[i];
                    }
                }
            } catch (e) {
            }

        }
        a.splice(0, 1);
        if (a.length != 0) {
            addselects(a, b);
        }
    }

    var htmla = '<div class="ncsc-mansong-rule"><span >商品参数&nbsp;<input name="para_name[]" class="inputL input_smallL" type="text">，</span><span>参数值&nbsp;<input name="para_value[]" class="inputL input_smallL" type="text"></span></div>';
    $("#addattr").click(function () {
        var num = $(".ncsc-mansong-rule").length;
        if (num <= 11) {
            $(".attr").append(htmla);
        } else {
            layer.msg('参数最多添加十二个！！！');
        }
    });
    //减少商品属性  规格
    $("#reduceattr").click(function () {
        var num = $(".ncsc-mansong-rule").length;
        if (num != 0) {
            $(".attr div:last-child").remove();
        }
    });
</script>